package com.ocom.webapi.controller;

import com.ocom.common.constant.PayConfigUrl;
import com.ocom.common.constant.PayHandleUrl;
import com.ocom.common.constant.WebApiServiceUrl;
import com.ocom.common.entity.typehandler.EntityCcbBusinessInfo;
import com.ocom.common.request.payconfig.CcbPosDeviceRequest;
import com.ocom.common.request.payconfig.GetCcbPosListRequest;
import com.ocom.common.request.payhandle.GetCcbDeleteBusinessRequest;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.common.vo.ccb.CcbzhshAddUserVo;
import com.ocom.common.vo.ccb.GetCcbAccountListVo;
import com.ocom.webapi.feign.PayConfigClientService;
import com.ocom.webapi.feign.PayHandleFeignService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@PreAuthorize("@pms.hasRole('ROLE_WEB')" ) //
public class CcbSmartLifeController {
    @Resource
    private PayConfigClientService payConfigClientService;
    @Resource
    private PayHandleFeignService payHandleFeignService;

    /**
     * 5.6.1 获取账户信息列表（CcbAccount/onShow）
     *
     * @param request
     * @return
     */
    @PostMapping(WebApiServiceUrl.Url_CcbAccountOnShow)
    public Result getCcbAccountList(@RequestBody @Valid GetCcbAccountListVo request) {
        return payConfigClientService.getCcbAccountList(request);
    }

    /**
     * 5.6.31 获取商家列表
     *
     * @param request
     * @return
     */
    @PostMapping(WebApiServiceUrl.Url_CcbAccountBusinessList)
    public Result getCcbBusinessList(@RequestBody GetCcbDeleteBusinessRequest request) {
        return payConfigClientService.getCcbBusinessList(request);
    }

    /**
     * 5.6.34 移除商家（CcbAccount/businessRemove）
     *
     * @param request
     * @return
     */
    @PostMapping(WebApiServiceUrl.Url_CcbAccountBusinessRemove)
    public Result getCcbDeleteBusiness(@RequestBody GetCcbDeleteBusinessRequest request) {
        Result ret = payConfigClientService.getCcbDeleteBusiness(request);
        return ret;
    }

    //5.6.41 获取柜台列表
    @PostMapping(WebApiServiceUrl.Url_CcbAccountPosList)
    public Result getCcbPosList(@RequestBody GetCcbPosListRequest request) {
        return payConfigClientService.getCcbPosList(request);
    }

    //5.6.43 设备与柜台解绑
    @PostMapping(WebApiServiceUrl.Url_CcbAccountUnbindDevice)
    public Result unbindCcbPosDevice(@RequestBody CcbPosDeviceRequest request) {
        Result ret = payConfigClientService.unbindCcbPosDevice(request);
        return ret;
    }

    //5.6.44 获取未绑定柜台的设备列表
    @PostMapping(WebApiServiceUrl.Url_CcbAccountNoBindDeviceLis)
    public Result getCcbNoPosDeviceList(@RequestBody GetCcbPosListRequest request) {
        Result ret = payConfigClientService.getCcbNoPosDeviceList(request);
        return ret;
    }

    //5.6.45 设备绑定柜台（CcbAccount/bindDevice）
    @PostMapping(WebApiServiceUrl.Url_CcbAccountBindDevice)
    public Result bindCcbPosDevice(@RequestBody CcbPosDeviceRequest request) {
        Result ret = payConfigClientService.bindCcbPosDevice(request);
        return ret;
    }

    /**
     * 5.6.2 用户签约（CcbAccount/sign）
     *
     * @param request
     * @return
     */
    @PostMapping(WebApiServiceUrl.Url_CcbAccountSign)
    public Result ccbSign(@RequestBody @Valid CcbzhshAddUserVo request) {
        return payHandleFeignService.ccbzhshAddUser(request);
    }

    //5.6.32 添加商家
    @PostMapping(WebApiServiceUrl.Url_CcbAccountBusinessAdd)
    public Result newBusiness(@RequestBody EntityCcbBusinessInfo request) {
        Result ret = payHandleFeignService.newBusiness(request);
        return ret;
    }

    //5.6.33 修改商家信息
    @PostMapping(WebApiServiceUrl.Url_CcbAccountBusinessModify)
    public Result updateBusiness(@RequestBody EntityCcbBusinessInfo request) {
        return payHandleFeignService.updateBusiness(request);
    }

    //5.6.42 增加柜台
    @PostMapping(WebApiServiceUrl.Url_CcbAccountPosAdd)
    public Result posAdd(@RequestBody EntityCcbBusinessInfo request) {
        return payHandleFeignService.updateBusiness(request);
    }

}
